var t = getApp();

Page({
    data: {
        teamId: "",
        platform: "ios",
        data: [],
        key: ""
    },
    clickSearch: function(a) {
        0 == this.data.key.length ? t.util.showToast("请输入关键词") : this.loadData();
    },
    clickInvite: function(a) {
        var e = a.currentTarget.dataset.teamid, n = a.currentTarget.dataset.name;
        console.log(e + n), e.length > 0 ? t.util.showToast(n + "已加入了其它团队") : this.inviteData(a.currentTarget.dataset.accesstoken);
    },
    keyInput: function(t) {
        var a = t.detail.value;
        this.setData({
            key: a
        });
    },
    loadData: function() {
        var a = this;
        t.network.post({
            url: t.url.listTeamMemberSearch,
            params: {
                teamId: a.data.teamId,
                key: a.data.key
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(e) {
                1 == e.data.result ? a.setData({
                    data: e.data.data.users
                }) : t.util.showToast(e.data.message);
            },
            fail: function() {
                t.util.showToast("查找失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    inviteData: function(a) {
        var e = this;
        t.network.post({
            url: t.url.inviteJoinTeam,
            params: {
                teamId: e.data.teamId,
                key: e.data.key,
                inviteAccessToken: a
            },
            before: function() {
                wx.showLoading({
                    title: "正在发送邀请"
                });
            },
            success: function(a) {
                t.util.showToast(a.data.message);
            },
            fail: function() {
                t.util.showToast("查找失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.hideLoading();
            }
        });
    },
    onLoad: function(t) {
        var a = wx.getSystemInfoSync();
        this.setData({
            teamId: t.teamId,
            platform: a.platform
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});